package main

import (
	"edu-common/nacos/boot"
	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
	"github.com/gogf/gf/contrib/registry/etcd/v2"
	"github.com/gogf/gf/contrib/rpc/grpcx/v2"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gctx"
	"user/internal/cmd"
)

func main() {
	boot.InitNacos("edu", "user", "config.yaml")
	//boot.InitNacos("edu", "user", "etcd.yaml.bak") //不能重复加载，否则被覆盖
	ctx := gctx.GetInitCtx()

	// 检查是否可用
	//g.Dump(g.Cfg().Available(ctx))

	// 输出所有配置
	//g.Dump(g.Cfg().Data(ctx))
	address, err := g.Cfg().Get(ctx, "etcd.address")
	if err != nil {
		panic(err)
	}
	//fmt.Println(etcd)
	grpcx.Resolver.Register(etcd.New(address.String()))
	cmd.Main.Run(ctx)

	/*************本地配置************
	//var ctx = gctx.New()
	//conf, err := g.Cfg("etcd").Get(ctx, "etcd.address")
	//if err != nil {
	//	panic(err)
	//}
	//
	//var address = conf.String()
	//grpcx.Resolver.Register(etcd.New(address))
	//
	//cmd.Main.Run(ctx)
	/*************本地配置*************/
}
